﻿<?php
/**
 * This is the file to define BaseObject.
 * 
 * @author	Justin Yoo
 * @version	0.0.1.0001
 * @package	KYR.Core
 * 
 */

//	Checks if this file is called within the framework; otherwise terminates.
if (!defined("IS_FRAMEWORK") || !IS_FRAMEWORK)	header("Location: http://".$_SERVER["HTTP_HOST"]."/error/404");

/**
 * This is class BaseObject that defines basic properties of each class inherited.
 *
 * Defines basic properties of each class inherited.
 * 
 * @author	Justin Yoo
 * @package	KYR.Core
 * @abstract
 * 
 */
abstract class BaseObject
{
	private $_properties = null;
	
	/**
	 * Initiates the BaseObject class.
	 *
	 * @access	public
	 *
	 */
	public function __construct()
	{
		$this->_properties = array();
	}
	
	/**
	 * Returns the property called by name.
	 *
	 * @access	public
	 * @param	string	$name	Name of the property.
	 * @return	mixed			Returns the named property.
	 *
	 */
	public function __get($name)
	{
		if (array_key_exists($name, $this->_properties))
			return $this->_properties[$name];
		else
			return null;
	}
	
	/**
	 * Sets the property to the given name.
	 *
	 * @access	public
	 * @param	string	$name	Name of the property.
	 * @param	mixed	$value	Value of the property.
	 *
	 */
	public function __set($name, $value)
	{
		$this->_properties[$name] = $value;
	}
	
	/**
	 * Checks if the property is set or not.
	 *
	 * @access	public
	 * @param	string	$name	Name of the property.
	 * @return	bool			Returns if the property is set or not.
	 *
	 */
	public function __isset($name)
	{
		return isset($this->_properties[$name]);
	}
	
	/**
	 * Clears the property of the name.
	 *
	 * @access	public
	 * @param	string	$name	Name of the property.
	 *
	 */
	public function __unset($name)
	{
		unset($this->_properties[$name]);
	}
	
	/**
	 * Gets the list of objects names.
	 *
	 * @access	protected
	 * @abstract
	 * @param	string	$type	Type of object to get names.
	 * @return	array			Returns the list of object names.
	 *
	 */
	abstract protected function GetObjectNames_($type);
}
?>
